
#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H

#include <GL/glew.h>
#include <vector>

#include "SDL/SDL.h"
#include "Matrix4.h"
#include "DisplayObject.h"

namespace Krengine
{
	class Environment
	{
		public:
			Environment( int windowWidth, int windowHeight, bool _3D = true );
			~Environment();

			void attachObject( DisplayObject& dispObj );

			/* starts rendering frames */
			void render( void (*update)() );
		private:
			Environment();
			/* no copying allowed */
			Environment( const Environment& );
			Environment& operator=( const Environment& );

			/* the window where everything is rendered in */
			SDL_Surface *window;
			/* width and height of the window */
			int width;
			int height;

			/* The environments projection matrix */
			Matrix4 projectionMatrix;

			/* indicated if the environment has a window setup and is running. NOTE: this doesn't indicate if it's rendering or not */
			bool running;
			
			/* used in glClear(). 2D and 3D projections each have their own renderbit flags. */
			GLbitfield renderbitFlags;

			//TODO FIXME
			std::vector<DisplayObject*> displayList;

			void catchSDLEvents();

			void exitProgram( int code );
	};
}

#endif